<!--
 * @Author: your name
 * @Date: 2021-08-13 10:27:02
 * @LastEditTime: 2021-08-16 15:26:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \系统学习\VueProject\vue02\supermall\src\views\home\childComps\HomeSwiper.vue
-->
<template>
    <swiper>
        <swiper-item v-for="(item,index) in banners" :key="index">
            <a :href="item.link">
                <img :src="item.image" alt="" @load="imageLoad">
            </a>
        </swiper-item>
    </swiper>
</template>

<script>
import {Swiper,SwiperItem} from 'components/common/swiper'
export default {
    name:'HomeSwiper',
    props:{
        banners:{
            type:Array,
            default(){
                return []
            }
        }
    },
    data(){
        return {
            isLoad:false
        }
    },
    components:{
        Swiper,
        SwiperItem
    },
    methods:{
        imageLoad(){
            // console.log('imageLoad');
            // 只会发送一次图片加载完成
            if(!this.isLoad){
                this.$emit('swiperImageLoad')
                this.isLoad = true
            }
        }
    }
}
</script>

<style>

</style>
